
require("config")
require("framework.init")
require("framework.shortcodes")
require("framework.cc.init")

local MyApp = class("MyApp", cc.mvc.AppBase)

function MyApp:ctor()
    MyApp.super.ctor(self)
    self.objects_ = {}
    --self.bullets_ = {}
    --self.enemys_ ={}

    app.score = 0 

    self.enemy_list_in_scene={}
end

function MyApp:run()
    CCFileUtils:sharedFileUtils():addSearchPath("res/")
    CCFileUtils:sharedFileUtils():addSearchPath("res/wx/")
    CCFileUtils:sharedFileUtils():addSearchPath("res/wx/wechatoldgame/")


    --self:enterScene("MainScene")
    --self:enterScene("ListAllPlistImgScene",{"assets/wechatoldgame/spritesheets/gameArts-hd.plist","assets/wechatoldgame/spritesheets/gameArts-hd.png"})
    --self:enterScene("ListAllPlistImgScene",{"spritesheets/gameArts-hd.plist","spritesheets/gameArts-hd.png"})
    self:enterScene("WXPlaneScene")
end

function MyApp:setObject(id, object)
    assert(self.objects_[id] == nil, string.format("MyApp:setObject() - id \"%s\" already exists", id))
    self.objects_[id] = object
end

function MyApp:getObject(id)
    assert(self.objects_[id] ~= nil, string.format("MyApp:getObject() - id \"%s\" not exists", id))
    return self.objects_[id]
end

function MyApp:isObjectExists(id)
    return self.objects_[id] ~= nil
end

function MyApp:degrees2radians(angle)
    return angle * 0.01745329252
end

function MyApp:radians2degrees(angle)
    return angle * 57.29577951
end

function MyApp:remove_enemy( enemy )
    for index = #app.enemy_list_in_scene, 1, -1 do
        local tmp_ = app.enemy_list_in_scene[index]
        if tmp_ == enemy then
            table.remove(app.enemy_list_in_scene, index)
        end
    end
end

function MyApp:add_enemy( enemy )
    app.enemy_list_in_scene[#app.enemy_list_in_scene + 1] = enemy
    print("#app.enemy_list_in_scene"..#app.enemy_list_in_scene)
end


return MyApp
